package com.hskn.hss.utils;

import com.hskn.hss.module.messageFlowRecords.domain.MessageFlowRecords;
import com.hskn.hss.module.messageFlowRecords.service.IMessageFlowRecordsService;
import com.hskn.hss.module.user.entity.User;
import com.hskn.hss.module.user.mapper.UserMapper;
import com.hskn.hss.module.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundSetOperations;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.TimeUnit;

/**
 *  工具类
 *
 * @author ccm
 **/
@SuppressWarnings(value = { "unchecked", "rawtypes" })
@Component
public class UpdateCache
{
    @Autowired
    public IMessageFlowRecordsService messageFlowRecordsService;
    @Resource
    public UserMapper userMapper;


    public int insertMessageFlowRecordsOnly(Integer flag, MessageFlowRecords messageFlowRecords){
       if(flag==null||flag==0){
           return 0;
       }
       User user=userMapper.selectById(messageFlowRecords.getUserId());
        if (user!=null) {
            messageFlowRecords.setUserName(user.getName());
        }
        return messageFlowRecordsService.insertMessageFlowRecordsOnly(messageFlowRecords);
    }

}
